package cn.lopr.im.android.utils;

import com.google.gson.Gson;

import java.lang.reflect.Type;
import java.util.Map;

/**
 * @author shuangyang7
 * @date 2021/5/17 21:22
 */
public class GsonUtil {
    private static Gson gson = new Gson();

    public static <T> T jsonToObject(String value, Class<T> c) {
        return gson.fromJson(value, c);
    }

    public static <T> String TTOString(T t) {
        return gson.toJson(t);
    }

    public static <T> String objectToJson(T value) {
        return gson.toJson(value);
    }

    public static <T> T mapToObject(Object map, Class<T> c) {
        return gson.fromJson(gson.toJson(map), c);
    }

    public static <T> T mapToObject(Map<String, Object> map, Class<T> c) {
        return gson.fromJson(gson.toJson(map), c);
    }

    public static <T> T mapToObject(Object map, Type c) {
        return gson.fromJson(gson.toJson(map), c);
    }


}
